﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsResumeDAL
/// </summary>
public class clsResumeDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsResumeDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public List<IN_TB_RESUME_MST> GetAllResume()
    {
        try
        {
            List<IN_TB_RESUME_MST> objIN_TB_RESUME_MST = new List<IN_TB_RESUME_MST>();
            objIN_TB_RESUME_MST = (from obj in objInstantNaukriDataContextDataContext.IN_TB_RESUME_MSTs
                                   select obj).ToList();
            return objIN_TB_RESUME_MST;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_RESUME_MST GetResumeById(int ID)
    {
        try
        {
            IN_TB_RESUME_MST objIN_TB_RESUME_MST = new IN_TB_RESUME_MST();
            objIN_TB_RESUME_MST = (from obj in objInstantNaukriDataContextDataContext.IN_TB_RESUME_MSTs
                                   where obj.ID == ID
                                   select obj).SingleOrDefault();
            return objIN_TB_RESUME_MST;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_RESUME_MST GetResumeByUserId(int UserId)
    {
        try
        {
            IN_TB_RESUME_MST objIN_TB_RESUME_MST = new IN_TB_RESUME_MST();
            objIN_TB_RESUME_MST = (from obj in objInstantNaukriDataContextDataContext.IN_TB_RESUME_MSTs
                                   where obj.USER_ID == UserId
                                   select obj).SingleOrDefault();
            return objIN_TB_RESUME_MST;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveResume(IN_TB_RESUME_MST objIN_TB_RESUME_MST)
    {
        try
        {
            IN_TB_RESUME_MST objIN_TB_RESUME_MSTD = new IN_TB_RESUME_MST();
            objIN_TB_RESUME_MSTD = (from obj in objInstantNaukriDataContextDataContext.IN_TB_RESUME_MSTs
                                    where obj.ID == objIN_TB_RESUME_MST.ID
                                    select obj).SingleOrDefault();
            if (objIN_TB_RESUME_MSTD != null)
            {
                objIN_TB_RESUME_MSTD.ID = objIN_TB_RESUME_MST.ID;
                objIN_TB_RESUME_MSTD.USER_ID = objIN_TB_RESUME_MST.USER_ID;
                objIN_TB_RESUME_MSTD.KEY_SKILLS = objIN_TB_RESUME_MST.KEY_SKILLS;
                objIN_TB_RESUME_MSTD.RESUME_HEADLINE = objIN_TB_RESUME_MST.RESUME_HEADLINE;
                objIN_TB_RESUME_MSTD.RESUME_SUMMARY = objIN_TB_RESUME_MST.RESUME_SUMMARY;
                objIN_TB_RESUME_MSTD.TOTAL_EXP = objIN_TB_RESUME_MST.TOTAL_EXP;
                objIN_TB_RESUME_MSTD.FUNCTIONAL_AREA = objIN_TB_RESUME_MST.FUNCTIONAL_AREA;
                objIN_TB_RESUME_MSTD.CTC = objIN_TB_RESUME_MST.CTC;
                objIN_TB_RESUME_MSTD.CURRENT_DESIGNATION = objIN_TB_RESUME_MST.CURRENT_DESIGNATION;
                objIN_TB_RESUME_MSTD.PREFERRED_LOCATION = objIN_TB_RESUME_MST.PREFERRED_LOCATION;

                objIN_TB_RESUME_MSTD.CURRENT_LOCATION = objIN_TB_RESUME_MST.CURRENT_LOCATION;
                objIN_TB_RESUME_MSTD.STATUS = objIN_TB_RESUME_MST.STATUS;
                objIN_TB_RESUME_MSTD.RESUME_PATH = objIN_TB_RESUME_MST.RESUME_PATH;
                objIN_TB_RESUME_MSTD.MODIFIED_ON = DateTime.Now;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_RESUME_MSTD.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_RESUME_MSTs.InsertOnSubmit(objIN_TB_RESUME_MST);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_RESUME_MST.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
}
